package com.example.network.retrofit

import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer

/**
 * 模拟服务器返回数据
 */
class ServerMocker() {
    private var server = MockWebServer()
    var url: String = ""

    init {
        server.start()
        val response = MockResponse()
            .setResponseCode(200)
            .setBody(
                """[
                      {
                        "id": "5",
                        "version": "5.5",
                        "name": "Clash of Clans"
                      },
                      {
                        "id": "6",
                        "version": "7.0",
                        "name": "Boom Beach"
                      },
                      {
                        "id": "7",
                        "version": "3.5",
                        "name": "Clash Royale"
                      }
                    ]"""
            )
        server.enqueue(response)
        url = server.url("/").toString()
    }

}